package net.roobook.cms.modules.admin.service;

import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.roobook.cms.common.entity.SearchEntity;
import net.roobook.cms.common.service.CrudService;
import net.roobook.cms.modules.admin.dao.MenuMapper;
import net.roobook.cms.modules.admin.dao.PermissionMapper;
import net.roobook.cms.modules.admin.entity.Menu;
import net.roobook.cms.modules.admin.entity.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author cos
 * @email 327878610@qq.com
 * @link https://roobook.net
 * @Description 权限Service
 * @date 2023/9/25 15:29
 **/
@Service
public class PermissionService extends CrudService<PermissionMapper, Permission> {

    @Autowired
    private PermissionMapper permissionMapper;

    @Autowired
    private MenuMapper menuMapper;


    public Permission queryMenuById(String id) {
        Permission permission = permissionMapper.selectByPrimaryKey(id);
        if(StrUtil.isNotBlank(permission.getMenuId())) {
            Menu menu = menuMapper.selectByPrimaryKey(permission.getMenuId());
            permission.setMenuName(menu.getMenuName());
        }
        return permission;
    }


}
